package cn.rocksolid.sport.common.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.io.Serializable;

@Data
public abstract class IdEntity implements Serializable {
  /**
   * Random serialVersionUID
   */
  private static final long serialVersionUID = 1L;
  /**
   *
   */
  @TableId
  private String id;

  @Override
  public int hashCode() {
    return new HashCodeBuilder().append(this.getId()).hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof IdEntity) {
      return StringUtils.equals(this.getId(), ((IdEntity) obj).getId());
    }
    return false;
  }
}
